home *** CD-ROM | disk | FTP | other *** search
- IOSTREAM(3C) Last changed: 1-12-99
-
-
- NNAAMMEE
- iioossttrreeaamm - Buffering, formatting and input/output
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<iioossttrreeaamm..hh>>
- ccllaassss ssttrreeaammbbuuff ;;
- ccllaassss iiooss ;;
- ccllaassss iissttrreeaamm :: vviirrttuuaall ppuubblliicc iiooss ;;
- ccllaassss oossttrreeaamm :: vviirrttuuaall ppuubblliicc iiooss ;;
- ccllaassss iioossttrreeaamm :: ppuubblliicc iissttrreeaamm,, ppuubblliicc oossttrreeaamm ;;
- ccllaassss iissttrreeaamm__wwiitthhaassssiiggnn :: ppuubblliicc iissttrreeaamm ;;
- ccllaassss oossttrreeaamm__wwiitthhaassssiiggnn :: ppuubblliicc oossttrreeaamm ;;
- ccllaassss iioossttrreeaamm__wwiitthhaassssiiggnn :: ppuubblliicc iioossttrreeaamm ;;
-
- ccllaassss IIoossttrreeaamm__iinniitt ;;
-
- eexxtteerrnn iissttrreeaamm__wwiitthhaassssiiggnn cciinn ;;
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn ccoouutt ;;
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cceerrrr ;;
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cclloogg ;;
-
- ##iinncclluuddee <<ffssttrreeaamm..hh>>
- ccllaassss ffiilleebbuuff :: ppuubblliicc ssttrreeaammbbuuff ;;
- ccllaassss ffssttrreeaamm :: ppuubblliicc iioossttrreeaamm ;;
- ccllaassss iiffssttrreeaamm :: ppuubblliicc iissttrreeaamm ;;
- ccllaassss ooffssttrreeaamm :: ppuubblliicc oossttrreeaamm ;;
-
- ##iinncclluuddee <<ssttrrssttrreeaamm..hh>>
- ccllaassss ssttrrssttrreeaammbbuuff :: ppuubblliicc ssttrreeaammbbuuff ;;
- ccllaassss iissttrrssttrreeaamm :: ppuubblliicc iissttrreeaamm ;;
- ccllaassss oossttrrssttrreeaamm :: ppuubblliicc oossttrreeaamm ;;
-
- ##iinncclluuddee <<ssttddiioossttrreeaamm..hh>>
- ccllaassss ssttddiioobbuuff :: ppuubblliicc ssttrreeaammbbuuff ;;
- ccllaassss ssttddiioossttrreeaamm :: ppuubblliicc iiooss ;;
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- The C++ iostream package declared in iioossttrreeaamm..hh and other header files
- consists primarily of a collection of classes. Although originally
- intended only to support input/output, the package now supports
- related activities such as incore formatting. This package is a
- mostly source-compatible extension of the earlier stream I/O package,
- described in _T_h_e _C++ _P_r_o_g_r_a_m_m_i_n_g _L_a_n_g_u_a_g_e by Bjarne Stroustrup.
-
- In the iostream man pages, character refers to a value that can be
- held in either a cchhaarr or uunnssiiggnneedd cchhaarr. When functions that return an
- iinntt are said to return a character, they return a positive value.
- Usually, such functions can also return EEOOFF (-1) as an error
- indication. The piece of memory that can hold a character is referred
- to as a byte. Thus, either a cchhaarr** or an uunnssiiggnneedd cchhaarr** can point to
- an array of bytes.
-
- The iostream package consists of several core classes, which provide
- the basic functionality for I/O conversion and buffering, and several
- specialized classes derived from the core classes. Both groups of
- classes are described on this man page.
-
- CCoorree CCllaasssseess
- The core of the iostream package is comprised of the following
- classes:
-
- ssttrreeaammbbuuff
- This is the base class for buffers. It supports insertion (also
- known as ssttoorriinngg or ppuuttttiinngg) and extraction (also known as
- ffeettcchhiinngg or ggeettttiinngg) of characters. Most members are inlined for
- efficiency. The public interface of class ssttrreeaammbbuuff is described
- in ssbbuuff..ppuubb(3C) and the protected interface (for derived classes)
- is described in ssbbuuff..pprroott(3C).
-
- iiooss This class contains state variables that are common to the
- various stream classes, such as error states and formatting
- states. See iiooss(3C) for more information.
-
- iissttrreeaamm
- This class supports formatted and unformatted conversion from
- sequences of characters fetched from ssttrreeaammbbuuffs. See iissttrreeaamm(3C)
- for more information.
-
- oossttrreeaamm
- This class supports formatted and unformatted conversion to the
- sequence of characters stored into a ssttrreeaammbbuuff. See oossttrreeaamm(3C)
- for more information.
-
- iioossttrreeaamm
- This class combines iissttrreeaamm and oossttrreeaamm. It is intended for
- situations in which bidirectional operations (inserting into and
- extracting from a single sequence of characters) are desired.
- See iiooss(3C) for more information.
-
- istream_withassign
- ostream_withassign
- iostream_withassign
-
- These classes add assignment operators and a constructor with no
- operands to the corresponding class without assignment. The
- predefined streams (see below) cciinn, ccoouutt, cceerrrr, and cclloogg, are objects
- of these classes. See iissttrreeaamm(3C), oossttrreeaamm(3C), and iiooss(3C) for more
- information.
-
- IIoossttrreeaamm__iinniitt
- This class is present for technical reasons relating to
- initialization. It has no public members. The IIoossttrreeaamm__iinniitt
- constructor initializes the predefined streams (listed below).
- Because an object of this class is declared in the iioossttrreeaamm..hh
- header file, the constructor is called once each time the header
- is included (although the real initialization is only done once),
- and therefore the predefined streams will be initialized before
- they are used. In some cases, global constructors may need to
- call the IIoossttrreeaamm__iinniitt constructor explicitly to ensure the
- standard streams are initialized before they are used.
-
- PPrreeddeeffiinneedd SSttrreeaammss
- The following streams are predefined:
-
- cciinn The standard input (file descriptor 0).
-
- ccoouutt The standard output (file descriptor 1).
-
- cceerrrr Standard error (file descriptor 2). Output through this stream
- is unit-buffered, which means that characters are flushed after
- each inserter operation. (See the oossttrreeaamm::::oossffxx(()) description in
- the oossttrreeaamm(3C) man page and the iiooss::::uunniittbbuuff description in the
- iiooss(3C) man page.)
-
- cclloogg This stream is also directed to file descriptor 2, but unlike
- cceerrrr, the output is buffered.
-
- cciinn, cceerrrr, and cclloogg are tied to ccoouutt so that any use of these will
- cause ccoouutt to be flushed.
-
- In addition to the core classes previously enumerated, the iostream
- package contains additional classes derived from them and declared in
- other headers. Programmers may use these or may choose to define
- their own classes derived from the core iostream classes.
-
- CCllaasssseess ddeerriivveedd ffrroomm ssttrreeaammbbuuff
- Classes derived from ssttrreeaammbbuuff define the details of how characters
- are produced or consumed. Derivation of a class from ssttrreeaammbbuuff (the
- pprrootteecctteedd iinntteerrffaaccee) is discussed in ssbbuuff..pprroott(3C). The following
- buffer classes are available:
-
- ffiilleebbuuff
- This buffer class supports I/O through file descriptors. Members
- support opening, closing, and seeking. Common uses do not
- require the program to manipulate file descriptors. See
- ffiilleebbuuff(3C).
-
- ssttddiioobbuuff
- This buffer class supports I/O through stdio FFIILLEE structs. It is
- intended for use when mixing C and C++ code. New code should
- prefer to use ffiilleebbuuffs. See ssttddiioobbuuff(3C) for more information.
-
- ssttrrssttrreeaammbbuuff
- This buffer class stores and fetches characters from arrays of
- bytes in memory (i.e., strings). See ssssbbuuff(3C).
-
- CCllaasssseess ddeerriivveedd ffrroomm iissttrreeaamm,, oossttrreeaamm,, aanndd iioossttrreeaamm
- Classes derived from iissttrreeaamm, oossttrreeaamm, and iioossttrreeaamm specialize the
- core classes for use with particular kinds of ssttrreeaammbbuuffs. These
- classes are as follows:
-
- iiffssttrreeaamm
- ooffssttrreeaamm
- ffssttrreeaamm
- These classes support formatted I/O to and from files. They use
- a ffiilleebbuuff to do the I/O. Common operations (such as opening and
- closing) can be done directly on streams without explicit mention
- of ffiilleebbuuffs. See ffssttrreeaamm(3C) for more information.
-
- iissttrrssttrreeaamm
- oossttrrssttrreeaamm
- These classes support in core formatting.
- They use a ssttrrssttrreeaammbbuuff. See ssttrrssttrreeaamm(3C) for more information.
-
- ssttddiioossttrreeaamm
- This class specializes iioossttrreeaamm for stdio FFIILLEEs. See
- ssttddiioossttrreeaamm..hh for more information.
-
- NNOOTTEESS
- Parts of the ssttrreeaammbbuuff class of the old stream package that should
- have been private were public. Most usage will compile properly, but
- code that depends on details, including classes that were derived from
- ssttrreeaammbbuuffs, will have to be rewritten.
-
- Performance of programs that copy from cciinn to ccoouutt may sometimes be
- improved by breaking the tie between cciinn and ccoouutt and doing explicit
- flushes of ccoouutt.
-
- The header file ssttrreeaamm..hh exists for compatibility with the earlier
- stream package. It includes iioossttrreeaamm..hh, ssttddiioo..hh, and some other
- headers, and it declares some obsolete functions, enumerations, and
- variables. Some members of ssttrreeaammbbuuff and iiooss (not discussed in these
- man pages) are present only for backward compatibility with the stream
- package.
-
- SSEEEE AALLSSOO
- iiooss(3C), ssbbuuff..ppuubb(3C), ssbbuuff..pprroott(3C), ffiilleebbuuff(3C), ssttddiioobbuuff(3C),
- ssssbbuuff(3C), iissttrreeaamm(3C), oossttrreeaamm(3C), ffssttrreeaamm(3C), ssttrrssttrreeaamm(3C),
- mmaanniipp(3C)
-
- This man page is available only online.
-